package person.bing.fbcloud.leetcode;

/**
 * @author: mengfanbing
 * @date: 2020/11/3 9:39
 */
public class Q941 {
    public static void main(String[] args) {
        int[] A = {1,2,1,3};
        boolean b = validMountainArray(A);
        System.out.println(b);
    }

    public static boolean validMountainArray(int[] A) {
        if (A == null){
            return false;
        }
        int length = A.length;
        if (length < 3){
            return false;
        }
        int index = 0;
        int start=0;
        int end=length-1;
        while (start<end){
            if (A[start+1]>A[start]){
                start++;
            }else {
                index = start;
                break;
            }
        }
        if (index == 0){
            return false;
        }
        for (int i=index;i<length-1;i++){
            if (A[i+1] >= A[i]){
                return false;
            }
        }
        return true;
    }
}
